package cn.webrx;

import java.util.Calendar;
import java.util.Timer;
import java.util.TimerTask;

public class T5 {
    public static void main(String[] args) {
        Timer timer = new Timer();
        //timer.schedule(new TimerTask() {
        //    public void run() {
        //        System.out.printf("%tT%n",System.currentTimeMillis());
        //    }
        //}, 2000, 1000);
        //
        //timer.schedule(new TimerTask() {
        //    public void run() {
        //        System.out.printf("时间：%tT%n",System.currentTimeMillis());
        //    }
        //}, 5000);

        //timer.schedule(new TimerTask() {
        //    @Override
        //    public void run() {
        //        System.out.println("关机....");
        //    }
        //},10*60*1000);

        Calendar c = Calendar.getInstance();
        c.set(Calendar.SECOND,20);


        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("关机");
                timer.cancel();
            }
        },c.getTime(),5000);
    }
}
